from cpapp.repr import ReprAble

class VersionInfo(ReprAble):

    def __init__(self, env, version_name, version_code):
        self.env = env
        self.short_version_name = version_name
        self.version_code = version_code
        self.version_name = version_name

        version_name_postfix = version_code
        if env != 'prod':
            version_name_postfix = '%s.%s' % (version_code, env)

        self.full_version_name = '%s.%s' % (version_name, version_name_postfix)

    def to_properties(self):
        env = self.env
        application_id_suffix_for_debug = ''
        if 'dev' in env or 'sandbox' in env:
            application_id_suffix_for_debug = '.dev'

        data = {
            'ENV': self.env,
            'APPLICATION_ID_SUFFIX_FOR_DEBUG': application_id_suffix_for_debug,
            'VERSION_NAME': self.version_name,
            'VERSION_CODE': self.version_code,
        }
        return data
